//
//  PopView.m
//  ZZLogistics
//
//  Created by 辰领科技 on 15/11/27.
//  Copyright © 2015年 辰领科技. All rights reserved.
//

#import "PopView.h"
@interface PopView ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)void(^complect)(NSInteger index);

@end
@implementation PopView


//违章查询结果  传入  @【用户名，违章情况】 数组
- (instancetype)initWithDealNumber:(NSString *)dealNumber Complect:(void(^)(NSInteger index))complect{
    self = [super init];
    if (self) {
        _complect = complect;
        self.frame = flexibleFrame(CGRectMake(20, 140, 280, 208), NO);
        self.layer.cornerRadius = 6*VerticalRatio();
        
        UIImageView * image = [[UIImageView alloc]initWithFrame:flexibleFrame(CGRectMake(122, 25, 36, 36), NO)];
        image.image = [UIImage imageNamed:@"paySuccess1"];
        
        UIImageView * backImage = [[UIImageView alloc]initWithFrame:flexibleFrame(CGRectMake(255, -45, 25, 45), NO)];
        backImage.image = [UIImage imageNamed:@"paySuccess2"];
        
        UILabel * label = [[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(0, 72, 280, 15), NO)];
        label.font = [UIFont systemFontOfSize:18*VerticalTexeRatio()];
        label.textColor = [UIColor colorWithWhite:0.204 alpha:1.000];
        label.textAlignment = NSTextAlignmentCenter;
        label.textColor = [UIColor colorWithWhite:0.255 alpha:1.000];
        label.text = @"订单支付成功";
        
        UILabel * thankLabel = [[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(0, 96, 280, 15), NO)];
        thankLabel.font = [UIFont systemFontOfSize:12*VerticalTexeRatio()];
        thankLabel.textColor = [UIColor colorWithWhite:0.255 alpha:1.000];
        thankLabel.textAlignment = NSTextAlignmentCenter;
        thankLabel.text = @"感谢您在凡人街网上商城购物。";
   
        
        UILabel * numberLabel = [[UILabel alloc]initWithFrame:flexibleFrame(CGRectMake(0, 127 , 280, 15), NO)];
        numberLabel.font = [UIFont systemFontOfSize:15*VerticalRatio()];
        numberLabel.textAlignment = NSTextAlignmentCenter;
        numberLabel.textColor = [UIColor colorWithWhite:0.255 alpha:1.000];
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"订单号：%@",dealNumber]];
        [str addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0.859 green:0.161 blue:0.161 alpha:1.000] range:NSMakeRange(4,dealNumber.length)];
        numberLabel.attributedText = str;
        
        
        UIView * buttonBackView = [[UIView alloc]initWithFrame:flexibleFrame(CGRectMake(0, 156, 280, 52), NO)];
        buttonBackView.layer.cornerRadius = 6*VerticalRatio();
        buttonBackView.backgroundColor = [UIColor colorWithWhite:0.937 alpha:1.000];
        
        UIView * maskView = [[UIView alloc]initWithFrame:flexibleFrame(CGRectMake(0, 0, 280, 9), NO)];
        maskView.backgroundColor = [UIColor whiteColor];
       
        
        UIView * line = [[UIView alloc]initWithFrame:flexibleFrame(CGRectMake(139, 0, 1, 52), NO)];
        line.backgroundColor = [UIColor colorWithWhite:0.843 alpha:1.000];
       
        NSArray * nameArray = @[@"查看详情",@"继续购物"];
        for (int i = 0; i<2; i++) {
            UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.backgroundColor = [UIColor clearColor];
            button.frame = flexibleFrame(CGRectMake(140*i, 9, 140, 43), NO);
            [button setTitle:nameArray[i] forState:UIControlStateNormal];
            [button setTitleColor:[UIColor colorWithWhite:0.255 alpha:1.000] forState:UIControlStateNormal];
            button.titleLabel.font = [UIFont systemFontOfSize:15*VerticalTexeRatio()];
            button.tag = 100+i;
            [button addTarget:self action:@selector(actionHandel:) forControlEvents:UIControlEventTouchUpInside];
            [buttonBackView addSubview:button];
        }
        
        [buttonBackView addSubview:line];
        [buttonBackView addSubview:maskView];
        [self addSubview:image];
        [self addSubview:backImage];
        [self addSubview:buttonBackView];
        [self addSubview:numberLabel];
        [self addSubview:thankLabel];
        [self addSubview:label];
    }
return self;
}


- (void)actionHandel:(UIButton*)sender{
    if (sender.tag<200) {
        _complect(sender.tag-100);
    }
    
    
    [self hide];
}


@end